﻿-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[ControlsJsonFormat]
@FormID int
AS
BEGIN
	 SELECT cast(FormControlID as varchar(50)) as id,
	 case 
		when cast(ParentControlID as varchar(50)) = 0 then '#'
		else isnull(cast(ParentControlID as varchar(50)),'#') END as parent,
	 ControlName as [text],
	 '{"opened":"true"}' as state,
     '{"sort":"' +  cast(sort as varchar(20)) + '"}'   as li_attr
	  FROM FormControls 
	  where FormID = @FormID
	  order by FormControls.[Sort]
END
